package alvarodelrosal.chat.server.modelo.chataction;

import alvarodelrosal.chat.server.infraestructura.ChatPersistenceManager;
import alvarodelrosal.chat.server.modelo.ChatConnection;
import alvarodelrosal.chat.server.modelo.ChatUser;
import java.util.List;

public class ChatGetUserData implements ChatAction {

    @Override
    public String getName() {
        return "GetUserData";
    }

    @Override
    public boolean needsAdminPrivileges() {
        return false;
    }

    @Override
    public boolean needsLogin() {
        return true;
    }

    @Override
    public String doAction(ChatConnection connection, List<String> parameters) {
        ChatUser user = ChatPersistenceManager.getPersistenceManager().
                getTheUser(Integer.parseInt(parameters.get(0)));
        
        return "GetUserData<:@:>" + user.getUserId() + "<:@:>" + 
                user.getName() + "<:@:>" + user.getMail() + "<:@:>" + 
                user.isAdmin();
    }
    
}
